package com.ithao.controller;

import com.ithao.entity.Result;
import com.ithao.pojo.Dict;
import com.ithao.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description ：数据字典控制器
 * @version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/dict")
public class DictController {

    @Autowired
    private DictService dictService;

    @RequestMapping("findListByType")
    public Result findListByType(Integer typeId) {
        try {
            log.info("Dict findListByType typeId:{}", typeId);
            List<Dict> dictList = dictService.selectListByType(typeId);
            return new Result(true, "获取成功", dictList);
        } catch (RuntimeException e) {
            log.error("Dict findListByType", e);
            return new Result(false, "获取失败");
        }
    }

    /**
     * 查询所有
     */
    @RequestMapping("/findList")
    public Result findList() {
        List<Dict> cityList = dictService.findList();
return new Result(true,"查找成功",cityList);

    }
}
